// components/registerStateTag/registerStateTag.js
import util from "../../utils/util.js"
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item: {
      // 属性名
      type: Object,
      value: {},
    },
  },

  

  /**
   * 组件的初始数据
   */
  data: {
    statusMap: {
      1: 'ing',
      2: 'will',
      3: 'end',
    },
    statusTextMap: {
      1: '正在报名',
      2: '即将报名',
      3: '结束报名',
    },
  },
  lifetimes:{
    // attached(){
    //   var props = this.data.item
    //   console.log("------------veforetime:",props)
    //   props.registration_begin = this.format(props.registration_begin)
    //   props.registration_end = this.format(props.registration_end)
    //   console.log("------------aftertime:",props)
    //   this.setData({
    //     item: {
    //       ...props
    //     }
    //   })
    // }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    format:function(release_time) {
      const time_a = util.formatTime(new Date(release_time)) //此时得到形如2021-11-23
      // console.log(time_a)
      const year = time_a.substr(0, 4)
      let month = time_a.substr(5, 2)
      let day = time_a.substr(8, 2)
      //去掉前导0
      if (month[0] == '0') {
        month = month.substring(1)
      }
      if (day[0] == '0') {
        day = day.substring(1)
      }
      const time_b = year + '-' + month + "-" + day  //此时得到形如2021-11-23
      // console.log(time_b)
      return time_b;
    }
  }
})
